package com.nulldev.util.crypto.api2.encryptors;

import java.nio.charset.Charset;

import com.nulldev.util.crypto.api2.Cryptable;
import com.nulldev.util.io.ZipUtils;
import com.nulldev.util.other.CharsetUtil;

public class ZIP extends Cryptable{

	public ZIP() {
		super("zip");
	}

	@Override
	public String encrypt(String object, String pass) {
		return this.encrypt(object, pass, CharsetUtil.getCharset());
	}

	@Override
	public String decrypt(String object, String pass) {
		return this.decrypt(object, pass, CharsetUtil.getCharset());	
	}

	@Override
	public String encrypt(String object, String pass, Charset charset) {
		if (charset == CharsetUtil.UTF_8) {
			return ZipUtils.zipS(object);
		}else {
			return ZipUtils.zipS16(object);
		}
	}

	@Override
	public String decrypt(String object, String pass, Charset charset) {
		if (charset == CharsetUtil.UTF_8) {
			return ZipUtils.unzipS(object);
		}else {
			return ZipUtils.unzipS16(object);
		}
	}

}
